' filename: DBASE.TXT author: ANDY KELLETT date: February 1992 ' ' This file is provided "as-is" to help programmers write code to ' read/write/view dBASE .DBF files. This information was used to ' create programs which I have tested and actually work. For more ' information, see the sources at the end of this document. -Thanks '---------------------------------------------------------- DBASE.TXT - Layout of dBASE .DBF files for Programmers dBASE (TM) Ashton-Tate byte description 1 dBASE version, value of 3 w/o a .DBT file, value of 131 with a .DBT file 2 year of last update to the file 3 month " " " 4 day " " " 5-8 total number of records in file 9-10 number of bytes in header (end of header marked by a byte value of 13) 11-12 individual record length 13-32 reserved 20 bytes (for multiuser dBASE ??) The following PowerBasic code will map the entire header into HEADER$$ for you: MAP HEADER$$ * 32, 1 AS VERSION$$, 1 AS YEAR$$, 1 AS MONTH$$,_ 1 AS DAY$$, 4 AS TOT.RECORDS$$, 2 AS HEADER.SIZE$$,_ 2 AS RECORD.LENGTH$$, 20 AS FILLER$$ The two byte fields contain numbers in low-byte/high-byte format common in Intel processors. If the values 05 02 were present, the actual value would be: 05 + (256 * 02) = 517 The four byte field for total number of records is handled a bit differently. If the hexadecimal values were 0F C1 01 00 then the actual value would be: 00 01 C1 0F . Following the file header are individual 32 byte headers for each field. You will need to use the (number of bytes in the header) from the file header to calculate how many fields there are. It will then be a matter of looping to read each individual field header and storing it one at a time. byte description 10 Field name, padded with CHR$(0) if needed 1 filler (always 0 ??) 1 Field type (Character, Numeric, Logical, Memo, Date) 4 filler (used for data address in RAM while in memory) 1 Field width 1 Number of decimal places ( CHR$(0) if not numeric type) 14 reserved The following PowerBasic code will map the entry for a single dBASE field into FIELDHEADER$$ for you: MAP FIELDHEADER$$ * 32, 10 AS FIELD.NAME$$, 1 AS FILLER1$$, _ 1 AS FIELD.TYPE$$, 4 AS FILLER2$$, 1 AS FIELD.WIDTH$$,_ 1 AS DECIMALS$$, 14 AS FILLER3$$ Once you've split FIELDHEADER$$ into its individual fields, you can move them into a table (for example) to easily handle .DBF files with many fields. '---------------------------------------------------------- ' Information on the structure of dBASE .DBF files were ' obtained from the following two sources: ' ' dBASE III Plus Programmer's Reference Guide pp.859 - 875 ' by Alan Simpson ( 1987 SYBEX Inc.) No dBASE programmer ' should ever be more than arms-length away from this book. ' ' BASIC Techniques and Utilities p. 251 by Ethan Winer ' ( 1991 Ziff-Davis Press ). Never thought about reading dBASE ' files from Turbo/PowerBasic until I stumbled over his ' easy-to-understand chapter. Did not use his code as a model. ' '